<?php
session_start();
isLogin();

if(isset($_POST["Submits"])){
	if($_REQUEST['act']=='modify'){
		$sql="update ".$prefix."newshop set n_name='".$_POST['n_name']."',n_link='".$_POST['n_link']."',n_typelink='".$_POST['n_typelink']."',n_typename='".$_POST['n_typename']."' where n_id=".$_REQUEST['n_id'];
		if(mysql_query($sql)){
			reload_js("修改成功","index.php?cmd=newshop");
		}else{
			reload_js("修改失败，原因：程序错误，请联系技术人员进行修改","index.php");
		}
	}else{
		$sql="insert into ".$prefix."newshop (n_name,n_link,n_typename,n_typelink) values('".$_POST['n_name']."','".$_POST['n_link']."','".$_POST['n_typename']."','".$_POST['n_typelink']."')";
		if(mysql_query($sql)){
			reload_js("添加成功","index.php?cmd=newshop");
		}else{
			reload_js("添加失败，原因：程序错误，请联系技术人员进行修改","index.php");
		}
	}
}

if($_REQUEST['act']=='del'){
	$sql="delete from ".$prefix."newshop where n_id=".$_REQUEST['n_id'];
	if(mysql_query($sql)){
		reload_js("","index.php?cmd=newshop");
	}else{
		reload_js("删除失败，原因：程序错误，请联系技术人员进行修改","index.php");
	}
}
?>
<script language="javascript" src="../templates/<?php echo $moban;?>/js/common.js"></script>
<script language="javascript">
changeWebTitle('最新推荐店铺管理');
</script>

<div class="ContentRight">
    <div class="ContentRightTop">
      <div class="BarLeft"></div>
      <div class="ContentRightTopText">最新推荐店铺管理</div>
      <div class="BarRight"></div>
      <div class="Cal"></div>
    </div>
    <div class="ContentRightBox">
	<form action="" name="linkform" method="post">
      <table width="100%" cellpadding="0" class="Table1" bordercolor="#4ab902" border="1" cellspacing="0">
        <tr>
          <td height="25" align="center">ID</td>
          <td align="center">店铺信息</td>
          <td align="center">操作</td>
        </tr>
		<?php 
		$result=mysql_query("select * from ".$prefix."newshop");
		while($arr=mysql_fetch_array($result)){
		?>
        <tr>
          <td width="19%" height="25" align="center"><?php echo $arr['n_id']?></td>
          <td width="52%" align="center">[<?php echo $arr['n_typename']?>]
		  	<a href="<?php echo $arr['n_link']?>" target="_blank"><?php echo $arr['n_name']?></a>		  </td>
          <td width="16%" align="center"><a href="<?php echo "?cmd=".$_REQUEST['cmd']."&n_id=".$arr['n_id']."&act=modify"?>">修改</a>&nbsp;<a href="<?php echo "?cmd=".$_REQUEST['cmd']."&n_id=".$arr['n_id']."&act=del"?>" onclick="return confirm('您确认删除该条记录？删除后将不可恢复！');">删除</a></td>
        </tr>
		<?php }
		
		if($_REQUEST['act']=='modify'){
			$result=mysql_query("select * from ".$prefix."newshop where n_id=".$_REQUEST['n_id']);
			if($arr=mysql_fetch_array($result)){
				$n_name=$arr['n_name'];
				$n_link=$arr['n_link'];
				$n_typename=$arr['n_typename'];
				$n_typelink=$arr['n_typelink'];
			}
		}
		?>
        <tr>
          <td height="25" colspan="3" align="right">&nbsp;</td>
        </tr>
        <tr>
          <td height="25" align="right">店铺名称：</td>
          <td colspan="2"><input name="n_name" type="text" id="n_name" size="40"  value="<?php echo $n_name?>"/></td>
        </tr>
        <tr>
          <td height="25" align="right">店铺链接：</td>
          <td colspan="2"><input name="n_link" type="text" id="n_link" size="40"  value="<?php echo $n_link?>"/>
          必须以http://开头</td>
        </tr>
        <tr>
          <td height="25" align="right">店铺类别：</td>
          <td colspan="2"><p>
            <label></label>
            <input name="n_typename" type="text" id="n_typename" size="40"  value="<?php echo $n_typename?>"/>
            <br />
          </p></td>
        </tr>
        <tr>
          <td height="25" align="right">类别链接：</td>
          <td colspan="2"><input name="n_typelink" type="text" id="n_typelink" size="40"  value="<?php echo $n_typelink?>"/></td>
        </tr>
        <tr>
          <td height="25" align="right">版权所有：</td>
          <td colspan="2"><a href="http://www.fengsh8.com" target="_blank">风尚淘客程序</a></td>
        </tr>
        <tr>
          <td height="25" align="right">&nbsp;</td>
          <td colspan="2">
            <input name="Submits" type="submit" id="Submits" value=" 提  交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="Reset" type="reset" id="Reset" value=" 重 置 " />          </td>
        </tr>
      </table>
	  </form>
    </div>
    <div class="Cal"></div>
  </div>